<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta charset="UTF-8">
		<title>结算页</title>
		<link rel="stylesheet" type="text/css" href="css/settleAccounts.css" />
		<link rel="stylesheet" type="text/css" href="css/prism_nav.css" />
		<link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>

	</head>
	<body>
			<jsp:include page="header_htl_2.jsp"></jsp:include>
			<ul class="nav nav-tabs col-xs-offset-3" style="width: 50%;">
			<li class="active"><a>购物车</a></li>
			</ul>
			<br />
			<table cellpadding="0" cellspacing="0" >
				<tr>
					<td><input type="checkbox" class="all"/></td>
					<td><span class="check">全选</span></td>
					<td><span class="tit">商品信息</span></td>
					<td><span class="price">单价（元）</span></td>
					<td><span class="num">数量</span></td>
					<td><span class="total">小计（元）</span></td>
					<!--<td><span class="weight">重量（Kg）</span></td>-->
					<td><span class="act">操作</span></td>
				</tr>
			
				<c:forEach items="${cart }" var="ca">
				<tr>
					<td><input type="checkbox" class="checkboxselect" class=""/></td>
					<td><img id="cartImg" src="${pageContext.request.contextPath}${ca.goods.goodsImg[0]!=null?ca.goods.goodsImg[0].imgUrl:''}"/></td>
					<td><span class="tit"><a href="">${ca.goods.goodName }&nbsp;-&nbsp;${ca.goods. goodInfo}</a></span>
					</td>
					<td>
						<span class="pri">${ca.goods.goodPrice }</span>
					</td>
					<td>
						<input type="hidden" value="${ca.goods.goodId }"/>
						<button class="reduce" style="border:none">-</button>
						<input type="text" id="goodNumber"  value="${ca.goodNumber }" class="number" style="border:none"/>
						<button class="add" style="border:none">+</button>
					</td>
					<td>
						<div class="item_amount">
						<span class="item_money">${ca.goods.goodPrice*ca.goodNumber }</span>
						</div>
					</td>
					<!--<td><span>0.42</span></td>-->
					<td><input type="image"  src="img/htmlItemImg/del.jpg" class="del"/></td>
				</tr>
				</c:forEach>
				<tr>
					<td colspan="5"></td>
					<td><span>合计：￥</span><span class="total_money">0</span></td>
					<td><button class="pay" id="pay" onclick="myselfinfo('orderDescription.jsp')">去结算</button></td>
				</tr>
			</table>
	<input type="hidden" value="${pass }" id="passInput"/>
	<div class="col-xs-offset-4 col-xs-4" id="confirmMsg">
   			<div class="input-group" style="margin-bottom:20px">
			    <label>请选择送货地址</label>
			    <select class="form-control" id="userSendAddress" name="userSendAddress">
			      <c:forEach items="${addressList }" var="list">
					<option value="${list.addressId }">${list.detailAddress }</option>
						</c:forEach>
			    </select>
			</div>
        <div class="input-group">
            <span class="input-group-addon">密码：</span>
            <input type="password" id="inputPassword" class="form-control" placeholder="请输入您的密码">
        </div>
        <br>
        <div class="input-group">
            <span class="input-group-addon">确认密码：</span>
            <input type="password" id="inputRePassword" class="form-control" placeholder="请输入确认密码">
        </div>
        <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2" style="margin-top:20px">
				<button class="btn btn-primary radius" id="submitButton">保存并提交</button>
				<button class="btn btn-warning radius" type="reset">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
		</div>
	</div>
	<div class="prism_wrap clearfix">
			<div class="prism_nav">
				<div class="prism_top_ad">
					<img src="img/prism_nav/5a267628N811711ba.jpg" />
				</div>
				<div class="prism_nav_center">
					<div id="prismPerson">
						<span class="prism_icon_tab">
							<img src="img/prism_nav/3.1我的.png" />
						</span>
						<u class="prism_icon_text">个人中心</u>
					</div>
					<div id="prismCart">
						<div class="prism_cart_tab">
							<span >
								<img src="img/prism_nav/3.1购物车.png" />
							</span>
						<div class="prism_cart_text"><a id="open_settle"></a>购物车</div>
						</div>
					</div>
					<div id="prismCoupon">
						<span class="prism_icon_tab">
							<img src="img/prism_nav/3.1优惠券.png" />
						</span>
						<u class="prism_icon_text">首页</u>
					</div>
				</div>
				<div class="prism_nav_btm">
					<div id="prismBacktop">
						<span class="prism_icon_tab">
							<img src="img/prism_nav/回到顶部.png" />
						</span>
					</div>
				</div>
			</div>
			</div>
			<iframe name="buttom" marginwidth=0 marginheight=0 scrolling="no" width=1280 height=120 src="buttom_htl.html" frameborder=0></iframe>
		<script type="text/javascript" src="js/jquery-3.2.1.js" ></script>
		<script type="text/javascript" src="js/prism_nav.js" ></script>
		<script type="text/javascript" src="js/settleAccounts.js" ></script>
		<script>
		$('#confirmMsg').hide();
		$('#pay').click(function(){
			/* alert($('.checkboxselect').length); */
			if($('.checkboxselect').length>0) {
				if($('.checkboxselect:checked').length>0){
					$('#confirmMsg').show();
				} else {
					$('#confirmMsg').hide();
					alert('你没有选中购买的商品');
				}
			} else {
				$('#confirmMsg').hide();
				alert('您的购物车没有商品，请添加')
			}
		});
		$('#submitButton').click(function(){
			var password = $('#passInput').val();
			var addressId = $('#userSendAddress').val();
			if($('#inputRePassword').val() != $('#inputPassword').val()) {
				alert('你输入的密码不一致');
			}else if( password == $('#inputPassword').val()) {
				alert("下单成功");
				window.location = "finished.cart?addressId=" + addressId;
			}else{
				alert('你输入的密码不正确');
			}
		});
		$('.prism_icon_text,.prism_icon_tab').click(function(){
			window.location = "search.goods?likeword=";
		});
		$('#prismPerson,#prism_icon_text').click(function(){
				window.location = "MyOrderServlet";
		});
    	</script>
	</body>
</html>
